<?php

namespace app\commands;

use Yii;
use yii\console\Controller;
use app\components\FileJob;

/**
 * JOB控制器
 */
class JobController extends Controller{

    /**
     * 推送任务
     */
    public function actionPush(){

        $jobs = [
            new FileJob([
                'file' => 'd:/queue1.txt',
                'content' => '任务1',
            ]),
            new FileJob([
                'file' => 'd:/queue2.txt',
                'content' => '任务2',
            ]),
            new FileJob([
                'file' => 'd:/queue3.txt',
                'content' => '任务3',
            ]),
        ];

        foreach($jobs as $key => $job){
            Yii::$app->queue->push($job);
            echo "Job ".$key." push success !";
        }

    }

}
